<template>
  <demoBlock title="动态更新提示">
    <vcu-cell is-link title="动态更新提示" @click="updateMessageToast" />
  </demoBlock>
</template>

<script setup>
import { Toast } from "../../../components";

const updateMessageToast = () => {
  const toast = Toast.loading({
    duration: 0,
    forbidClick: true,
    message: "倒计时 3 秒",
  });
  let second = 3;
  const timer = setInterval(() => {
    second--;
    if (second) {
      toast.message = `倒计时 ${second} 秒`;
    } else {
      clearInterval(timer);
      Toast.clear();
    }
  }, 1000);
};
</script>
